<?php

//包含公共文件
include '../../common/common.php';


//修改数据库
$username = $_COOKIE['username'];
$res = myUpdate($link , DB_TABLE_USER , ['afterlogin' => 0 , 'lasttime' => time()] , "username='$username'");
// var_dump($res);

if (!$res) {
	exit('退出登录失败<br /> <a href="'  . $_SERVER['HTTP_REFERER'] .'">返回上一页</a>');
}

//清空cookie内容 , 
setcookie('uid' , '' , time() - 1 , '/');
setcookie('username' , '' , time() - 1 , '/');
setcookie('afterlogin' , '' , time() - 1 , '/');

//跳转页面
echo '退出成功';
header('refresh:2; url=' . $webSite . 'index.php');

